from collections import defaultdict, Counter


class Solution:

    def countBalls(self, lowLimit: int, highLimit: int) -> int:
        dict_sum  = defaultdict(int)
        for i in range(lowLimit,highLimit+1):
            sum = 0
            for j in str(i):
                sum += int(j)
            dict_sum[sum]+=1
        cc = max(dict_sum,key=lambda x:dict_sum[x])
        print(dict_sum)
        return dict_sum[cc]


    def countBalls1(self, lowLimit: int, highLimit: int) -> int:
        count = Counter(sum(map(int, str(i))) for i in range(lowLimit, highLimit + 1))
        return max(count.values())


if __name__ == '__main__':
    low = 1
    high = 10
    solution = Solution()
    val = solution.countBalls(low,high)
    print(val)

    val1 = solution.countBalls1(low,high)
    print(val1)

    jj = 112
##  这个map有点神奇
    maps = map(int,str(jj))
    print(list(maps))
